﻿using System;
using System.Collections.Generic;
using Paulovich.Data;
using System.Collections.ObjectModel;
using System.Data;
using Paulovich.Data.SqlBuilder;

namespace DJJuninho.Business {

	[Table("Album")]
	public class Album: Persist  {

		#region fields & properties

		[PrimaryKeyField(IsIdentity=true)]
        public int AlbumId { get; set; }

		[Field]
        public string Name { get; set; }

		[Field]
        public string Description { get; set; }

		[Field]
        public string Photo { get; set; }

		#endregion

		#region constructors

		public Album()
			: base() {
		}

		public Album(params object[] keys)
			: base(keys) {
		}

		#endregion


        public static DataTable SelectOrderingByName()
        {

            try
            {

                var query = new SelectBuilder();

                query.Select.Add("AlbumId, Name");
                query.TableName = "Album";
                query.OrderBy = "Name";

                var command = new Command();

                command.CommandText = query.ToString();

                return (DataTable)command.ExecuteQuery(ReturnType.DataTable);

            }
            catch (Exception)
            {

                throw;
            }

        }
    }

}
